﻿@model List<string>
@{    
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript" src="@Url.Content("~/Scripts/Uploadify/swfobject.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/Uploadify/jquery.uploadify.v2.1.0.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Scripts/Uploadify/uploadify.css")" rel="stylesheet" type="text/css" />
<style type="text/css">
.grid_12 .gallery li 
{
     width:auto;
     margin-left:5px;    
}
.grid_4 .widget_body .widget_content li
{
   
    border-bottom:1px  dotted #c1c1c1;
 }
 .grid_4 .widget_body .widget_content li a
{
     padding-top:5px;
    padding-bottom:5px;
   display:block;
 }
 .grid_4 .widget_body .widget_content li a:hover, .blueli
{
    background: #2981be; /* Old browsers */
    background: -moz-linear-gradient(top, #2981be 0%, #1b5488 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2981be), color-stop(100%,#1b5488)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2981be 0%,#1b5488 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2981be 0%,#1b5488 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(top, #2981be 0%,#1b5488 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2981be', endColorstr='#1b5488',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(top, #2981be 0%,#1b5488 100%); /* W3C */
    -webkit-box-shadow: inset 0 1px 0 0 #5fa1ce, 0 1px 0 0px #e3e3e3;
    -moz-box-shadow: inset 0 1px 0 0 #5fa1ce, 0 1px 0 0px #e3e3e3;
    -ms-box-shadow: inset 0 1px 0 0 #5fa1ce, 0 1px 0 0px #e3e3e3;
    -o-box-shadow: inset 0 1px 0 0 #5fa1ce, 0 1px 0 0px #e3e3e3;
    box-shadow: inset 0 1px 0 0 #5fa1ce, 0 1px 0 0px #e3e3e3;
    
    color: #fff;
    border: 1px solid #13436d;
    text-shadow: 0 1px 1px #144570;
 }
</style>
<div class="grid_12 widget tabs first">
    <div class="widget_title clearfix">
        <h2>
            婚纱作品分类--@ViewBag.Category</h2>
        <ul class="sf-menu">
            <li><a id="btnLoad" class="btn blue right medium" href="#" title="上传作品至该分类" style="box-shadow: none">
                <span>上传作品至该分类</span></a>
                <div class="grid_8 widget" id="upload" style="margin: 0px; top: 25px; left: -250px;
                    width: 360px; display: none; position: absolute; z-index: 100">
                    <div class="widget_body">
                        <div class="widget_content">
                            <div class="msg notice">
                                <span>此处可以批量上传，上传的图片尽量保持在1M以内.</span> <a class="close" href="#" style="margin: 0px;
                                    padding: 0px">x</a>
                            </div>
                            <p>
                                <input id="fileInput1" name="fileInput1" type="file" /></p>
                            <label class="block">
                                <a class="btn grey left" id="btnClose"><span>【取 消】</span></a> 
                                <a class="btn blue right" id="btnSave"><span>【上 传】</span></a>
                            </label>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                </div>
            </li>
            <li><a id="Add" class="btn blue right medium" href="#" title="新增写真作品分类" style="box-shadow: none">
                <span>新增婚纱作品分类</span></a>                
                  <div id="AddDiv" class="grid_8 widget" style="margin: 0px; top: 25px; left: -345px; display: none; position: absolute; z-index: 100">
                            <div class="widget_body">
                                <div class="widget_content">
                                    <div class="msg notice">
                                        <span>请填写作品分类名称，并确保在20个字符内.</span> <a class="close" href="#" style="margin: 0px;
                                            padding: 0px">x</a>
                                    </div>
                                    <form id="AddForm" name="AddForm" action="@Url.Content("~/WeddingAdmin/WeddingCategoryAdd")" method="post">
                                    <label class="block" style="margin-bottom: 10px;">
                                        作品分类名称:</label>
                                    <input type="text" class="large" id="txtCategoryName" name="txtCategoryName" maxlength="25" />
                                    <label class="block" style="margin-top: 10px;">
                                        <a class="btn grey left" id="aClose"><span>【取 消】</span></a> 
                                        <a class="btn blue right" id="btnSubmit"><span>【保 存】</span></a>
                                    </label>
                                    </form>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                        </div>                   
            </li>            
        </ul>
    </div>
    <div class="widget_body">
        <div class="widget_content">
            <ul class="gallery">
                @foreach (var item in Model)
                {
                    <li><a href="@Url.Content(ViewBag.Path + item)" class="gallerythumb" title="@item">
                        <img src="@Url.Content(ViewBag.Path + "Thumbnail/" + item)" alt="@item" /></a>
                        <ul class="img_options">
                            <li><a href="@Url.Content(ViewBag.Path + item)" title="@item" rel="prettyPhoto[gallery]" class="btn">
                                查看</a></li>
                            <li><a href="@Url.Content("~/WeddingAdmin/DeleteWeddingPicture?name=" + Url.Encode(item) + "&category=" + Url.Encode(ViewBag.Category) + "&CategoryId=" + ViewBag.CategoryId)" class="btn" data="delete">
                                删除</a></li>
                            <li><a href="@Url.Content("~/WeddingAdmin/SetAsFrontCover?name=" + Url.Encode(item) + "&CategoryId=" + ViewBag.CategoryId)" class="btn">
                                设为封面</a></li>
                        </ul>                        
                    </li>
                }
            </ul>
            <div class="clear">
            </div>
        </div>
    </div>
</div>
<div class="grid_4 widget">
    <div class="widget_title clearfix">
        <ul style="float:left"><li>
            <a class="btn grey  right medium" href="@Url.Content("~/WeddingAdmin/WeddingCategoryList")" title="转到作品分类列表" style="box-shadow:none">
                <span>婚纱作品分类</span></a></li></ul>
    </div>
    <div class="widget_body">
        <div class="widget_content">
            @{Html.RenderAction("_categoryAdmin", "WeddingAdmin", new { photoType = "婚纱" });}
            <!-- List Ends -->
            <div class="clear">
            </div>
        </div>
    </div>
</div>
<div class="clear">
</div>
<script type='text/javascript'>
    $(document).ready(function () {
        $(".gallerythumb").bind("mouseenter", function () {
            $(".gallerythumb .btn").hide();
            $(this).parent().find(".btn").show();
        });
        $(".gallery").bind("mouseleave", function () {
            $(this).parent().find(".btn").hide();
        });
        $("a[rel^='prettyPhoto']").prettyPhoto({
            opacity: 0.9,
            show_title: true,
            social_tools: false
        });

        $(".gallery li a.btn[data='delete']").click(function () {
            return confirm("确定真的要删除该图片吗？");
        })

        $(".gallery li a img[src='@Url.Content("~/"+ViewBag.ThumPath)']").parent(0).after($("<span class='coverpage'></span>"));

        $("#btnSubmit").click(function () { $("#AddForm").submit(); });

        //上传
        $('#fileInput1').uploadify({
            'uploader': '@Url.Content("~/Scripts/Uploadify/uploadify.swf")',
            'script': '@Url.Content("~/ShowCase/Upload")',
            'folder': escape("/UpFiles/婚纱/@ViewBag.Category/"),
            'cancelImg': '@Url.Content("~/Scripts/Uploadify/cancel.png")',
            'fileExt': '*.jpg;*.gif;*.png',
            'fileDesc': 'Image Files (.JPG, .GIF,.PNG)',
            'sizeLimit': 1024 * 1024 * 2,
            'multi': true,
            'onAllComplete': fun
        });

        $("#btnClose").click(function () {
            $('#uploadify').uploadifyClearQueue();
            $('#upload').toggle();
        });

        $("#btnSave").click(function () {
            $('#fileInput1').uploadifyUpload();
        })
        $("#btnLoad").click(function () {
            $('#upload').toggle();
            return false;
        })

        $("#Add").click(function () {
            $('#AddDiv').toggle();
            return false;
        })

        $("#aClose").click(function () {
            $('#AddDiv').toggle();
            return false;
        })

        $('a[id="category-@ViewBag.CategoryId"]').attr("class", "blueli");

        // 字符验证  
        jQuery.validator.addMethod("string", function (value, element) {
            return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
        }, "只能包含中文字、英文字母、数字和下划线!");

        $("#AddForm").validate({
            rules: {
                txtCategoryName: {
                    required: true,
                    maxlength: 20,
                    string: true

                }
            },
            messages: {
                txtCategoryName: {
                    required: "请输入分类名称.",
                    maxlength: jQuery.format("分类名称必须小于{0}个字符.")
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo($(element).next());
                //$(error).parent(0).css("visibility", "visible");
            },
            submitHandler: function (form) {
                form.submit();
            },
            success: function (label) {
                label.html("&nbsp;").addClass("checked"); // set &nbsp; as text for IE
            }

        });

        $("#btnSubmit").click(function () { $("#AddForm").submit(); });
    });

    function fun(event, data) {
        $('#uploadify').uploadifyClearQueue();
        $('#upload').toggle();
        window.location.reload();
    }
</script>
